/**
 * 
 */
package com.keggview.application.xml.datatypes;

import com.thoughtworks.xstream.annotations.XStreamAlias;
import com.thoughtworks.xstream.annotations.XStreamAsAttribute;
import com.thoughtworks.xstream.annotations.XStreamOmitField;

//import org.dom4j.Element;

/**
 * @author Pablo
 * 
 * The substrate element specifies the substrate node of this reaction. The
 * attribute of this element is as follows.
 */
@XStreamAlias("substrate")
public class Substrate extends Base {

	/**
	 * The name attribute contains the KEGG identifier of the COMPOUND database
	 * or the GLYCAN database.
	 */
	@XStreamAsAttribute
	private String name;
	
	
	private Alt alt;
	@XStreamOmitField
	private Entry substrate;

	/**
	 * @param name
	 */
	public Substrate(String name) {
		super();
		this.name = name;
		this.alt = null;
		this.substrate = null;
		Registry.register(this);
	}

//	public Substrate(Element element) {
//		this.name = element.attributeValue("name");
//	}

	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}

	/**
	 * @param name the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * @return the alt
	 */
	public Alt getAlt() {
		return alt;
	}

	/**
	 * @param alt the alt to set
	 */
	public void setAlt(Alt alt) {
		this.alt = alt;
	}

	/**
	 * @return the substrate
	 */
	public Entry getSubstrate() {
		if (this.substrate == null) {
			this.substrate = Registry.nEntries.get(this.name);
		}
		return substrate;
	}

	/**
	 * @param substrate the substrate to set
	 */
	public void setSubstrate(Entry substrate) {
		this.substrate = substrate;
		this.name = this.substrate.getName();
	}
	
}
